package com.ruoyi.wx.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.WxUser;
import com.ruoyi.system.service.WxUserService;
import com.ruoyi.wx.pojo.vo.UserInfoVo;
import com.ruoyi.wx.service.WxUserWebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wx/user")
public class WxUserController {

    @Autowired
    private WxUserWebService wxUserWebService;
    @Autowired
    private WxUserService wxUserService;

    @GetMapping("/list")
    public AjaxResult getUserList() {
        Map<String, Object> userList = wxUserWebService.getUserList();
        return AjaxResult.success(userList);
    }


    @PostMapping("/info")
    public AjaxResult getUserInfo(@RequestBody List<UserInfoVo> userInfoVos) {
        Map<String, Object> userList = wxUserWebService.getUserInfo(userInfoVos);
        return AjaxResult.success(userList);
    }

    @PostMapping("/localinfo/{userId}")
    public AjaxResult getLocalUserInfo(@PathVariable("userId") int userId) {
         WxUser wxUser = wxUserService.queryById(userId);
        return AjaxResult.success(wxUser);
    }
    @GetMapping("/{id}")
    AjaxResult getUserById(@PathVariable("id") String id) {
        Integer integer = wxUserService.queryByUserId(id);
        return AjaxResult.success(integer);
    }
}
